package com.vijay;

import com.vijay.loadtimeweave.AsyncBean;
import org.springframework.aop.framework.AopProxyFactory;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;


@SpringBootApplication
@EnableAsync(mode = AdviceMode.ASPECTJ)
//@EnableAspectJAutoProxy
//@EnableLoadTimeWeaving(aspectjWeaving = EnableLoadTimeWeaving.AspectJWeaving.ENABLED)  instrument need importing
public class InstrumentBootApplication {

    public static void main(String[] args) {

        ConfigurableApplicationContext context = SpringApplication.run(InstrumentBootApplication.class, args);

        AsyncBean bean = context.getBean(AsyncBean.class);

        bean.asyncRun();

        System.out.printf("%s async run after\n",Thread.currentThread());


        bean.run();

        context.close();

    }

}
